<?php
/**
 * Function:
 * Description:
 * Abo 2018/10/11 14:39
 * Email: abo2013@foxmail.com
 */

class Client {
    # 调用activepush方法以后，会在cmd中打印出
    # client is PushMessage 主动推送消息 字眼

    /**
     * CURL请求
     * @param $data
     */
    public function curl($data)
    {
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, "http://127.0.0.1:9502");
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_HEADER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        curl_exec($curl);
        curl_close($curl);
    }

    /**
     * 主动触发
     */
    public function activepush()
    {
        $param['scene'] = '主动触发:主动推送消息';
        $this->curl($param);            // 主动推送消息
    }

    public function websocket()
    {

    }
}

( new Client() )->activepush();